
$('.btn-submit').on('click',function(){
    var title = $('[name="title"]').val().trim();
    var space = $('[name="space"]:checked').val()
    var content = $('[name="content"]').val().trim();
   
    if(!title){
       showMsg($('.error-info'),'Please input title');
       return
    }

    if(!space){
       showMsg($('.error-info'),'Please select space');
       return
    }

    if(!content){
        showMsg($('.error-info'),'Please  input content');
        return
    }


    $.ajax({
        url:'/question',
        type:'POST',
        data:{
            title,
            space,
            content
        }
    }).done(function(res){
        if(res.success){
           window.location.href='/';
        }else{
           showMsg($('.error-info'),'email or password error');
        }
    }).fail(function(xhr){
        showMsg($('.error-info'),'Server error');
        console.log(xhr)
    });

});

